package com.lagou.jediscluster;

import org.junit.Test;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

public class JesterClusterTest {

    @Test
    public void jedisCluster(){
        JedisPoolConfig conf = new JedisPoolConfig();
        Set<HostAndPort> jedisClusterNodes = new HashSet<>();

        jedisClusterNodes.add(new HostAndPort("192.168.80.121",7001));
        jedisClusterNodes.add(new HostAndPort("192.168.80.121",7002));
        jedisClusterNodes.add(new HostAndPort("192.168.80.121",7003));
        jedisClusterNodes.add(new HostAndPort("192.168.80.121",7004));
        jedisClusterNodes.add(new HostAndPort("192.168.80.121",7005));
        jedisClusterNodes.add(new HostAndPort("192.168.80.121",7006));
        jedisClusterNodes.add(new HostAndPort("192.168.80.121",7007));
        jedisClusterNodes.add(new HostAndPort("192.168.80.121",7008));

        JedisCluster jcd = new JedisCluster(jedisClusterNodes, conf);
        jcd.set("name:001","zhangfei");
        String value = jcd.get("name:001");
        System.out.println(value);
    }
}
